<template>
  <div>
    <input type="text" placeholder="请输入要搜索的关键字" v-if="isShowInput"  ref="change"/>
    <button @click="changeState" v-else>点击搜索</button>
  </div>
</template>

<script>
// dom.focus() 获取焦点
export default {
  data() {
    return {
     isShowInput: false
    }
  },
  methods: {
    changeState() {
      this.isShowInput = true
      this.$nextTick(() => {
        this.$refs.change.focus()
      })
    }
  } 
}
</script>

<style>
</style>